package com.hk.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hk.mapper.CurriculumMapper;
import com.hk.model.pojo.Curriculum;
import com.hk.model.vo.CurriculumVo;
import com.hk.result.PageResult;
import com.hk.service.CurriculumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;

@Service
public class CurriculumServiceImpl implements CurriculumService {
    @Autowired
    private CurriculumMapper curriculumMapper;

    @Override
    public PageResult list(Integer pageNum, Integer pageSize, String code, String name, String applicablePerson, Integer params, String beginCreateTime, String endCreateTime, String subject) {
        PageHelper.startPage(pageNum, pageSize);
        Page<CurriculumVo> curriculumVo = curriculumMapper.list(pageNum, pageSize, code, name, applicablePerson, params, beginCreateTime, endCreateTime, subject);
        return new PageResult(curriculumVo.getTotal(), curriculumVo.getResult());
    }

    @Override
    public void addSubject(Curriculum curriculum) {
        curriculumMapper.insert(curriculum);
    }

    @Override
    public Curriculum seleltId(Integer id) {
        return curriculumMapper.selectByIds(id);
    }

    /**
     * 根据id批量删除
     *
     * @param ids
     */
    @Override
    public void deleteBatchIds(Integer[] ids) {
        curriculumMapper.deleteBatchIds(Arrays.asList(ids));
    }
}
